#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

void do_ls(const char *name)
{
	DIR *dir = opendir(name);
	if(!dir)
		fprintf(stderr, "cannot open %s \n", name);
	else
	{

		struct dirent *p_rent;
		while((p_rent = readdir(dir)))
		{
			printf("%s\n", p_rent->d_name);
		}
		closedir(dir);

	}
}


int main(int argc, char **argv)
{
	if(argc==1)
		do_ls(".");
	else
	{
		while(--argv)
			do_ls(*argv);
	}
	
	return 0;

}
